package handel

import (
	"github.com/gin-gonic/gin"
	"surgeon-suite/modle"
)

func Show(c *gin.Context) {
	id := c.Query("id")
	var suite modle.Surgeon
	err := modle.DB.Where("id=?", id).Find(&suite).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "查询失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"data": suite,
		"msg":  "查询成功",
	})

}
func Up(c *gin.Context) {
	id := c.PostForm("id")
	surgeon_name := c.PostForm("surgeon_name")
	surgeon_type := c.PostForm("surgeon_type")
	content := c.PostForm("content")
	//var suite modle.Surgeon
	data := modle.Surgeon{
		SurgeonName: surgeon_name,
		SurgeonType: surgeon_type,
		Content:     content,
	}
	err := modle.DB.Where("id=?", id).Updates(data).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "修改失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "修改成功",
	})
	return
}
